local paiyi = fk.CreateSkill {

  name = "joy__paiyi",

  tags = {  },

}



paiyi:addEffect("active", {
  name = "joy__paiyi",
  anim_type = "control",
  card_num = 1,
  target_num = 1,
  expand_pile = "joy__zhonghui_quan",
  can_use = function(self, player)
    return #player:getPile("joy__zhonghui_quan") > 0 and player:usedSkillTimes(paiyi.name, Player.HistoryPhase) == 0
  end,
  target_filter = function(self, player, to_select, selected)
    return #selected == 0
  end,
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and player:getPileNameOfId(to_select) == "joy__zhonghui_quan"
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    room:moveCards({
      from = player.id,
      ids = effect.cards,
      toArea = Card.DiscardPile,
      moveReason = fk.ReasonPutIntoDiscardPile,
      skillName = paiyi.name,
    })
    target:drawCards(2, paiyi.name)
    if target:getHandcardNum() > player:getHandcardNum() then
      room:damage{
        from = player,
        to = target,
        damage = 1,
        skillName = paiyi.name,
      }
    end
  end,
})

return paiyi